package main

import (
	"flag"
	"fmt"
	"strconv"
	"time"

	"gitee.com/Liaojx/pi-benchmarking/pkg"
)

var (
	limit = flag.Int64("c", 10000000000, "计算次数")
	ncpus = flag.Bool("n", false, "使用多核心计算")
	manaul = flag.Bool("m", false, "启用非cpu评分模式计算pi")
)

func init() {
	flag.Parse()
}

func main() {
	if *manaul {
		var pi float64
		start := time.Now()
		if *ncpus {
			pi = pkg.LeibnizE(*limit)
		} else {
			pi = pkg.Leibniz(*limit)
		}
		end := time.Since(start)
		PI := strconv.FormatFloat(pi, 'f', 64, 64)
		fmt.Println(PI, end)
	} else {
		pkg.BeanchMarking()
	}
}
